package com.unism.unisdk.core;

import java.util.Map;

import com.unism.unisdk.common.enumObj.Protocol;

public class DefaultConfig {

	private String apiBasePackage;
	private String apiDomain;
	private FolwControl folwControl;
	private HttpConfig globalHttpConfig;
	private Map<String, HttpConfig> customHttpConfig;
    private Protocol protocol;
	public DefaultConfig() {
		this.apiBasePackage = "com.unism.unisdk.api";//https://oapi.dingtalk.com
		this.apiDomain = "http://127.0.0.1:8080";
		this.globalHttpConfig = new HttpConfig();
		this.folwControl = new FolwControl();
		this.protocol=Protocol.HTTP;
	}

	public Protocol getProtocol() {
		return protocol;
	}

	public void setProtocol(Protocol protocol) {
		this.protocol = protocol;
	}

	public String getApiBasePackage() {
		return this.apiBasePackage;
	}

	public void setApiBasePackage(String apiBasePackage) {
		this.apiBasePackage = apiBasePackage;
	}

	public String getApiDomain() {
		return this.apiDomain;
	}

	public void setApiDomain(String apiDomain) {
		this.apiDomain = apiDomain;
	}

	public FolwControl getFolwControl() {
		return this.folwControl;
	}

	public void setFolwControl(FolwControl folwControl) {
		this.folwControl = folwControl;
	}

	public HttpConfig getGlobalHttpConfig() {
		return this.globalHttpConfig;
	}

	public void setGlobalHttpConfig(HttpConfig globalHttpConfig) {
		this.globalHttpConfig = globalHttpConfig;
	}

	public Map<String, HttpConfig> getCustomHttpConfig() {
		return this.customHttpConfig;
	}

	public void setCustomHttpConfig(Map<String, HttpConfig> customHttpConfig) {
		this.customHttpConfig = customHttpConfig;
	}

	public static class FolwControl {
		private boolean isUse;
		private int maxQpm;
		private int threadPoolSize;

		public FolwControl() {
			this.isUse = true;
			this.maxQpm = 1500;
			this.threadPoolSize = 4;
		}

		public boolean getIsUse() {
			return this.isUse;
		}

		public void setIsUse(boolean isUse) {
			this.isUse = isUse;
		}

		public int getMaxQpm() {
			return this.maxQpm;
		}

		public void setMaxQpm(int maxQpm) {
			this.maxQpm = maxQpm;
		}

		public int getThreadPoolSize() {
			return this.threadPoolSize;
		}

		public void setThreadPoolSize(int threadPoolSize) {
			this.threadPoolSize = threadPoolSize;
		}
	}

	public static class HttpConfig {
		private int requestTimeout;
		private int readTimeout;
		private int maxRequestRetry;
		private int connectTimeout;

		public HttpConfig() {
			this.readTimeout = 30000;
			this.connectTimeout = 5000;
			this.maxRequestRetry = 0;
			this.requestTimeout = 60000;
		}

		public int getRequestTimeout() {
			return this.requestTimeout;
		}

		public void setRequestTimeout(int requestTimeout) {
			this.requestTimeout = requestTimeout;
		}

		public int getReadTimeout() {
			return this.readTimeout;
		}

		public void setReadTimeout(int readTimeout) {
			this.readTimeout = readTimeout;
		}

		public int getMaxRequestRetry() {
			return this.maxRequestRetry;
		}

		public void setMaxRequestRetry(int maxRequestRetry) {
			this.maxRequestRetry = maxRequestRetry;
		}

		public int getConnectTimeout() {
			return this.connectTimeout;
		}

		public void setConnectTimeout(int connectTimeout) {
			this.connectTimeout = connectTimeout;
		}
	}
}